home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / casm / au116-as.exe / UTIL / FILELINE.CPP < prev    next >
C/C++ Source or Header  |  1994-05-22  |  2KB  |  75 lines

  1. #include "..\au.hpp"
  2.  
  3. /* read_raw_line() gets a raw line from a text file
  4.    read_line()       gets a .cfg file line from a text file */
  5.  
  6. /************************************************************************/
  7. int HANDLE::read_raw_line(char *string)
  8. {
  9.     int c, string_pos=0;
  10.  
  11.     while ((c = read_char()) != EOF)
  12.     {
  13.         if (c=='\n' || c=='\r')
  14.             break;
  15.         string[string_pos++] = c;
  16.     }
  17.     if (string_pos==0 && c==EOF)
  18.         return EOF;
  19.  
  20.     string[string_pos] = '\0';
  21.     return 0;
  22. }
  23.  
  24. /************************************************************************/
  25. /* get a line of text from a file trim the spaces on the left            */
  26. /* and remove comments                                                    */
  27. /************************************************************************/
  28. int HANDLE::read_line(AU *au, char *string)
  29. {
  30.     int ret_code;
  31.     char *pos;
  32.  
  33.     ret_code = read_raw_line(string);
  34.  
  35.     pos = strchr(string, ';');     /* Remove comment */
  36.     if (pos != NULL)
  37.         *pos = '\0';
  38.  
  39.     subst_environ(au, string);
  40.  
  41.     if (string[0] == '\0' && ret_code == EOF)
  42.         return EOF;
  43.  
  44.     ltrim(string);
  45.     return 0;
  46. }
  47. /************************************************************************/
  48. /* get a word of text from a file trim the spaces on the left
  49.    and remove comments */
  50.  
  51. int HANDLE::read_word(char *string)
  52. {
  53.     int c, string_pos=0;
  54.  
  55.     while ((c = read_char()) != EOF)
  56.     {
  57.         if (!isspace(c))
  58.             break;
  59.         string[string_pos++] = c;
  60.     }
  61.     if (c==EOF)
  62.         return EOF;
  63.     string[string_pos++] = c;
  64.     while ((c = read_char())!=EOF)
  65.     {
  66.         if (isspace(c))
  67.             break;
  68.         string[string_pos++] = c;
  69.     }
  70.  
  71.     string[string_pos] = '\0';
  72.     return 0;
  73. }
  74.  
  75.